package com.tys.algorithm.beginner;

/**
 * 位运算
 */
public class Code1_PrintB {

    public static void main(String[] args) {
        int num = 2;
        print(num);

        int c = 5;
        int d = -c;
        d = (~c + 1); //表示-c
    }

    //打印二进制
    public static void print(int num) {
        for (int i = 31; i >= 0; i--) {
            System.out.print((num & (1 << i)) == 0 ? "0" : "1");
        }
        System.out.println();
    }

}
